import java.util.*;

public class demo2 {
    public static void main(String[] args) {
        int[] arr = {1,2,3,3,4,4,4,4,5,5,3,32,2,35,7};
        int[] arr1 = removal(arr);
        System.out.println(Arrays.toString(arr1));
    }

    private static int[] removal(int[] arr) {
        int[] arr1 = new int[arr.length];
        int cur = 0;
        int len = 1;
        arr1[cur++] = arr[0];
        Arrays.sort(arr);
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] != arr[i-1]){
                arr1[cur++] = arr[i];
                len ++;
            }
        }
        int[] arr2 = Arrays.copyOf(arr1,len);
        return arr2;
    }
}
